"3D image effect"
Bootstrap 4.1.1 Snippet by ALIMUL AL RAZY

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row">
<div class="ui"><button class="btn btn-default" id="btn">Toggle</button></div>
<div class="box fore-box"><div class="img fore"></div></div>
<div class="box bg-box"><div class="img bg"></div></div>
<script>
document.querySelector("#btn").onclick = function(e) {
var box = document.querySelector(".box");
box.classList.toggle("on");
e.preventDefault();
};
</script>
</div>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
* {
box-sizing: border-box;
}
.box {
position: absolute;
perspective: 400px;
width: 750px;
height: 478.75px;
overflow: hidden;
transform-style: preserve-3d;
transition: perspective 5s;
}
.fore-box {
z-index: 10;
}
.bg-box {
z-index: 5;
}
.img {
position: absolute;
top: 0;
left: 0;
width: 750px;
height: 478.75px;
transition: all 5s;
}
.fore {
z-index: 10;
background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/9332/hills-foreground.png);
background-size: cover;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: